package dragonsource 
{
	import caurina.transitions.properties.TextShortcuts;
	import caurina.transitions.Tweener;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author leef918@gmail.com
	 */
	public class HintDog extends Sprite 
	{
		static private var __instance:HintDog;
		static private var __stage:Stage;
		static public const DEFAULT_WIDTH:Number = 100;
		
		private var tf:TextField;
		
		public function HintDog() 
		{
			TextShortcuts.init();
			creattf();
		}
		
		private function creattf():void 
		{
			var style:TextFormat = new TextFormat();
			style.font = "黑体";
			style.size = 12;
			tf = new TextField
			tf.defaultTextFormat = style;
			tf.text = 'init...';
			tf.autoSize = TextFieldAutoSize.LEFT;
			tf.selectable = false;
			tf.background = true;
			//set to 
			__stage.addChild(tf);
			moveToCentrel();
		}
		
		static public function initialize(stg:Stage ):void 
		{
			if (stg == null) {
				throw(new Error('you MUST set an stage instance to use this class functionality'));
			}
				__stage=stg
		}
		
		static public function get instance():HintDog 
		{
			if (__instance == null) {
				__instance = new HintDog
			}
			
			return __instance
		}
		
		public function moveToCentrel():void 
		{
			__stage.addChild(this);
			tf.x=(__stage.stageWidth-DEFAULT_WIDTH)>>1
			tf.x=(__stage.stageHeight-tf.height)>>1
		}
		
		public function moveToLeftTop():void 
		{
			__stage.addChild(this);
			tf.x = tf.y = 5;
		}
		
		public function setContent(v:String):void 
		{
			//todo
			Tweener.addTween(tf, { _text:v,time:0.6,transition:'linear'} );
		}
	}
}